package com.mareas.web.jsf.component;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.model.SelectItem;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.mareas.web.model.Buque;
import com.mareas.web.service.GenericService;

@SuppressWarnings("restriction")
@ManagedBean
@RequestScoped
@Component
public class InplaceSelectBuqueBean {

	@Autowired
	private GenericService genericService;

	private List<Buque> buques;
	private List<SelectItem> buquesOptions = null;
	private int value;

	@PostConstruct
	public void init() {
		buquesOptions = new ArrayList<SelectItem>();

		buques = genericService.getAll(Buque.class);
		for (Buque buque : buques) {
			buquesOptions.add(new SelectItem(buque.getBuqueImo(), buque.getBuqueNombre()));
		}
	}

	public GenericService getGenericService() {
		return genericService;
	}

	public void setGenericService(GenericService genericService) {
		this.genericService = genericService;
	}

	public List<Buque> getBuques() {
		return buques;
	}

	public void setBuques(List<Buque> buques) {
		this.buques = buques;
	}

	public List<SelectItem> getBuquesOptions() {
		return buquesOptions;
	}

	public void setBuquesOptions(List<SelectItem> buquesOptions) {
		this.buquesOptions = buquesOptions;
	}

	public int getValue() {
		return value;
	}

	public void setValue(int value) {
		this.value = value;
	}

}
